<template>
  <div class="header">
    <div class="back" @click="goBack"></div>
    <h2 v-text="computedTitle"></h2>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        computedTitle: this.title.length > 10 ? this.title.substring(0, 10) + '...' : this.title
      }
    },
    props: ['title'],
    methods: {
      goBack () {
//        window.history.go(-1)
        this.$router.back(-1)
      }
    },
    created () {}
  }
</script>
<style scoped>
  .header {
    width: 7.5rem;
    height: 1.2rem;
    background-color: #5E88FF;
    position: relative;
  }

  .header .back {
    width: 0.4rem;
    height: 0.53rem;
    padding: 0.1rem;
    background: url('../../assets/images/sprite.png') no-repeat -0.75rem -0.7rem;
    background-size: 10rem 6rem;
    background-origin: content-box;
    position: absolute;
    left: 0.2rem;
    top: 0.3rem;
    z-index: 8888;
  }

  .header h2 {
    font-size: 0.36rem;
    line-height: 1.2rem;
    text-align: center;
    color: #fff;
    font-weight: 500;
  }

</style>
